|
|
|
|
|
|
|
On the other hand, the Hi-Lo algorithm often produces fine results, even for perspective projections. As long as the center of projection is not too close to the surface and does not lie too close to either the X-Y or Y-Z plane, the Hi-Lo algorithm may produce correct results. Figure 14.14 shows a perspective projection of a surface in which the Hi-Lo algorithm works correctly. |
|
|
|
|
|
|
|
|
Finally, the code presented earlier works only when the corner of the surface with the largest X and Z values is closest to the center of projection. You can write similar code to handle viewing from other directions. It may be easier, however, to apply a transformation to your data to rotate the surface rather than move the center of projection. |
|
|
|
|
|
|
|
|
The Hi-Lo algorithm uses two arrays to ensure that it never draws a line that will later be obscured by another part of the surface. This is very important when you are drawing on a plotter or other device that cannot erase. It is also important if you want to save a drawing in a metafile. Using the Hi-Lo algorithm ensures that any application that imports the metafile will display it correctly. For some complex surfaces, the algorithm may also remove a lot of data, substantially reducing the size of the metafile. |
|
|
|
|
|
|
|
|
While plotters cannot erase, computer monitors can. The Z-Order algorithm uses that fact to draw surfaces with hidden lines removed in a remarkably simple way. |
|
|
|
|
|
|
|
|
The Hi-Lo algorithm draws a surface's "rectangles" in order from front to back. Since one of these areas cannot be obscured by one that will be drawn later, the program can tell which parts of each area are visible. |
|
|
|
|
|
|
|
|
Figure 14.14
The Hi-Lo algorithm works for some perspective projections. |
|
|
|
|
|